package com.time.tell.the.truth.netty;

import com.time.tell.the.truth.netty.client.Client;
import com.time.tell.the.truth.netty.dto.User;
import com.time.tell.the.truth.netty.server.Server;
import io.netty.util.ResourceLeakDetector;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NettyApp {

  public static void main(String[] args) throws InterruptedException {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);

    new Thread(() -> new Server().start()).start();
    // 休眠2秒，确保服务端已启动
    Thread.sleep(2000);

    Client client = new Client();
    client.connect();

    User user = User.builder().name("tttt").age(18).build();
    for (int i = 0; i < 10000; i++) {
      client.send(user);
    }
  }
}
